/**
 * 游戏基本协议
 */
import { SocketHelper } from "SocketHelper";
const MAX_ROOMUSER_COUNT = 10;
const MAX_ROOMPLAYER_CARD_COUNT = 5;
const MAX_ROOM_CARD_COUNT = 10;
/*--------------------------------------CmdType_Casino--------------------------------------*/
export var Cmd;
(function (Cmd) {
    Cmd[Cmd["Casino_None"] = 0] = "Casino_None";
    Cmd[Cmd["Casino_CreateGame"] = 1] = "Casino_CreateGame";
    Cmd[Cmd["Casino_Join"] = 2] = "Casino_Join";
    Cmd[Cmd["Casino_BeginGame"] = 3] = "Casino_BeginGame";
    Cmd[Cmd["Casino_EndGame"] = 4] = "Casino_EndGame";
    Cmd[Cmd["Casino_BeginRound"] = 5] = "Casino_BeginRound";
    Cmd[Cmd["Casino_SitDown"] = 6] = "Casino_SitDown";
    Cmd[Cmd["Casino_StandUp"] = 7] = "Casino_StandUp";
    Cmd[Cmd["Casino_Quit"] = 8] = "Casino_Quit";
    Cmd[Cmd["Casino_Bet"] = 9] = "Casino_Bet";
    Cmd[Cmd["Casino_Reward"] = 10] = "Casino_Reward";
    Cmd[Cmd["Casino_ChangeUserState"] = 11] = "Casino_ChangeUserState";
    Cmd[Cmd["Casino_ChangeRoomCard"] = 12] = "Casino_ChangeRoomCard";
    Cmd[Cmd["Casino_ChangeRoomCardList"] = 13] = "Casino_ChangeRoomCardList";
    Cmd[Cmd["Casino_ChangePlayerInfoVo"] = 14] = "Casino_ChangePlayerInfoVo";
    Cmd[Cmd["Casino_ChangePlayerCard"] = 15] = "Casino_ChangePlayerCard";
    Cmd[Cmd["Casino_ChangePlayerCardList"] = 16] = "Casino_ChangePlayerCardList";
    Cmd[Cmd["Casino_OpenAction"] = 17] = "Casino_OpenAction";
    Cmd[Cmd["Casino_Action"] = 18] = "Casino_Action";
    Cmd[Cmd["Casino_CloseAction"] = 19] = "Casino_CloseAction";
    Cmd[Cmd["Casino_Tips"] = 20] = "Casino_Tips";
    Cmd[Cmd["Casino_CloseGame"] = 21] = "Casino_CloseGame";
    Cmd[Cmd["Casino_EndRound"] = 22] = "Casino_EndRound";
    Cmd[Cmd["Casino_ChangeAction"] = 23] = "Casino_ChangeAction";
    Cmd[Cmd["Casino_Result"] = 24] = "Casino_Result";
})(Cmd || (Cmd = {}));
export var CasinoType;
(function (CasinoType) {
    CasinoType[CasinoType["CasinoType_None"] = 0] = "CasinoType_None";
    CasinoType[CasinoType["CasinoType_TexasPoker"] = 1] = "CasinoType_TexasPoker";
    CasinoType[CasinoType["CasinoType_Count"] = 2] = "CasinoType_Count";
})(CasinoType || (CasinoType = {}));
class RoomPlayerGameVo {
    create(buffer) {
        let rlt = {};
        let parse = new SocketHelper(0);
        rlt.state = parse.getUInt(buffer);
        rlt.cardList = parse.getCharArray(buffer, MAX_ROOMPLAYER_CARD_COUNT);
        rlt.betCount = parse.getInt(buffer);
        return rlt;
    }
}
export class RoomPlayerInfo {
    constructor(buffer) {
        if (buffer) {
            let parse = new SocketHelper();
            this.uid = parse.getUInt64(buffer);
            this.userNick = parse.getString(buffer, 65);
            this.userImg = parse.getString(buffer, 257);
            this.isPresenter = parse.getChar(buffer);
            this.golds = parse.getInt64(buffer);
            this.sessionId = parse.getUInt64(buffer);
            this.dbId = parse.getUShort(buffer);
            this.srvId = parse.getUShort(buffer);
            this.lineId = parse.getUShort(buffer);
            this.platformId = parse.getInt(buffer);
            this.roomId = parse.getUInt64(buffer);
        }
    }
    toBuffer() {
        let buffer = Buffer.allocUnsafe(339);
        let write = new SocketHelper();
        write.putUInt64(buffer, this.uid);
        write.putString(buffer, this.userNick, 65);
        write.putString(buffer, this.userImg, 257);
        write.putInt(buffer, this.isPresenter);
        write.putUInt64(buffer, this.golds);
        return buffer;
    }
}
export class RoomVo {
    constructor(buffer) {
        let helper = new SocketHelper();
        this.gameType = helper.getInt(buffer);
        this.platformId = helper.getInt(buffer);
        this.roomId = helper.getUInt64(buffer);
        this.minJoinBets = helper.getInt(buffer);
        this.minBets = helper.getInt(buffer);
        this.maxBets = helper.getInt(buffer);
        this.isClose = helper.getChar(buffer);
        this.roomCardMaxCount = helper.getChar(buffer);
        this.roomCardList = helper.getShortArray(buffer, MAX_ROOM_CARD_COUNT);
        this.roomUserMaxCount = helper.getChar(buffer);
        let players = new Array();
        for (let i = 0; i < this.roomUserMaxCount; i++) {
            let item = {};
            let tmpbuffer = helper.getBuffer(buffer, 36);
            let infoBuffer = helper.getBuffer(tmpbuffer, 17);
            let info = new RoomPlayerInfo(infoBuffer);
            let gameBuffer = helper.getBuffer(tmpbuffer, 19);
            let game = new RoomPlayerGameVo().create(gameBuffer);
            item.info = info;
            item.gameVo = game;
            players.concat(item);
        }
        this.playerList = players;
        let createInfo = new RoomPlayerInfo(buffer.slice(buffer.byteLength - 361));
        this.createPlayer = createInfo;
    }
}
export class Tcm_Casino_CreateGame {
    toBuffer() {
        let buffer = Buffer.allocUnsafe(24);
        let helper = new SocketHelper();
        helper.putInt(buffer, this.gameType);
        helper.putInt(buffer, this.minJoinBets);
        helper.putInt(buffer, this.minBets);
        helper.putInt(buffer, this.maxBets);
        helper.putUInt64(buffer, this.roomId);
        return buffer;
    }
    // 每次投注最高数量 int
    constructor(obj) {
        this.gameType = obj.gameType;
        this.minJoinBets = obj.minJoinBets;
        this.minBets = obj.minBets;
        this.maxBets = obj.maxBets;
        this.roomId = obj.roomId;
    }
}
export class Tsm_Casino_CreateGame {
    constructor(buffer) {
        let helper = new SocketHelper();
        this.errorNo = helper.getInt(buffer);
        this.roomVo = new RoomVo(buffer.slice(4));
    }
}
export class Tcm_Casino_Join {
    constructor(obj) {
        this.roomId = obj.roomId;
    }
    toBuffer() {
        let buffer = Buffer.allocUnsafe(8);
        new SocketHelper().putUInt64(buffer, this.roomId);
        return buffer;
    }
}
export class Tsm_Casino_Join {
    constructor(buffer) {
        let read = new SocketHelper();
        this.errorNo = read.getInt(buffer);
        this.roomVo = new RoomVo(buffer.slice(4));
    }
}
export class Tcm_Casino_SitDown {
    constructor(o) {
        let info = new RoomPlayerInfo();
        info.uid = o.info.uid;
        info.userNick = o.info.userNick;
        info.userImg = o.info.userImg;
        info.isPresenter = o.info.isPresenter;
        info.golds = o.info.golds;
        this.info = info;
        this.index = o.index;
    }
    toBuffer() {
        let buffer = Buffer.allocUnsafe(369);
        let infoBuffer = this.info.toBuffer();
        buffer.copy(infoBuffer, 0, 365);
        let put = new SocketHelper(365);
        put.putInt(buffer, this.index);
        return buffer;
    }
}
export class Tsm_Casino_SitDown {
    constructor(buffer) {
        this.errorNo = new SocketHelper().getInt(buffer);
    }
}
export class Tcm_Casino_StandUp {
    constructor(obj) {
        this.index = obj.index;
    }
    toBuffer() {
        let buffer = Buffer.allocUnsafe(4);
        new SocketHelper().putInt(buffer, this.index);
        return buffer;
    }
}
export class Tsm_Casino_StandUp {
    constructor(buffer) {
        this.errorNo = new SocketHelper().getInt(buffer);
    }
}
export class Tsm_Casino_ChangePlayerInfoVo {
    constructor(buffer) {
        let read = new SocketHelper();
        this.gameType = read.getInt(buffer);
        this.index = read.getInt(buffer);
        let infoBuffer = buffer.slice(8);
        this.player = new RoomPlayerInfo(infoBuffer);
    }
}
export class Tcm_Casino_Quit {
    constructor(obj) {
        this.index = obj.index;
    }
    toBuffer() {
        let buffer = Buffer.allocUnsafe(4);
        new SocketHelper().putInt(buffer, this.index);
        return buffer;
    }
}
export class Tcm_Casino_Bet {
    constructor(obj) {
        this.memberId = obj.memberId;
        this.betType = obj.betType;
        this.golds = obj.golds;
    }
    toBuffer() {
        let buffer = Buffer.allocUnsafe(12);
        let helper = new SocketHelper();
        helper.putInt(buffer, this.memberId);
        helper.putInt(buffer, this.betType);
        helper.putInt(buffer, this.golds);
        return buffer;
    }
}
export class Tsm_Casino_Bet {
    constructor(buffer) {
        let read = new SocketHelper();
        this.errorNo = read.getInt(buffer);
        this.memberId = read.getInt(buffer);
        this.betType = read.getInt(buffer);
        this.golds = read.getInt(buffer);
        this.betCount = read.getInt(buffer);
        this.isPublic = read.getChar(buffer);
    }
}
export class Tcm_Casino_Reward {
    constructor(obj) {
        this.golds = obj.golds;
    }
    toBuffer() {
        let buffer = Buffer.allocUnsafe(4);
        new SocketHelper().putInt(buffer, this.golds);
        return buffer;
    }
}
export class Tsm_Casino_Reward {
    constructor(buffer) {
        let read = new SocketHelper();
        this.errorNo = read.getInt(buffer);
        this.golds = read.getInt(buffer);
    }
}
export class Tsm_Casino_ChangeUserState {
    constructor(buffer) {
        let read = new SocketHelper();
        this.index = read.getInt(buffer);
        this.state = read.getUInt(buffer);
    }
}
export class Tsm_Casino_ChangeRoomCard {
    constructor(buffer) {
        let read = new SocketHelper();
        this.index = read.getInt(buffer);
        this.card = read.getShort(buffer);
    }
}
export class Tsm_Casino_ChangeRoomCardList {
    constructor(buffer) {
        let read = new SocketHelper();
        this.roomCardList = read.getShortArray(buffer, MAX_ROOM_CARD_COUNT);
    }
}
export class Tsm_Casino_ChangePlayerCard {
    constructor(buffer) {
        let parse = new SocketHelper();
        this.memberId = parse.getInt(buffer);
        this.cardIndex = parse.getInt(buffer);
        this.card = parse.getShort(buffer);
        this.isPublic = parse.getChar(buffer);
    }
}
export class Tsm_Casino_ChangePlayerCardList {
    constructor(buffer) {
        let parse = new SocketHelper();
        this.memberId = parse.getInt(buffer);
        this.cardList = parse.getShortArray(buffer, MAX_ROOMPLAYER_CARD_COUNT);
        this.isPublic = parse.getChar(buffer);
    }
}
export class Tsm_Casino_OpenAction {
    constructor(buffer) {
        let parse = new SocketHelper();
        this.gameType = parse.getInt(buffer);
        this.actionType = parse.getInt(buffer);
        this.action = parse.getUInt(buffer);
        this.p1 = parse.getInt(buffer);
        this.p2 = parse.getInt(buffer);
        this.p3 = parse.getInt(buffer);
        this.p4 = parse.getInt(buffer);
    }
}
/**
 * 先不用
 */
export class Tcm_Casino_Action {
    constructor(obj) {
        this.actionType = obj.actionType;
        this.action = obj.action;
        this.p1 = obj.p1;
        this.p2 = obj.p2;
        this.p3 = obj.p3;
        this.p4 = obj.p4;
    }
    toBuffer() {
        let buffer = Buffer.allocUnsafe(24);
        let write = new SocketHelper();
        write.putInt(buffer, this.actionType);
        write.putUInt(buffer, this.action);
        write.putInt(buffer, this.p1);
        write.putInt(buffer, this.p2);
        write.putInt(buffer, this.p3);
        write.putInt(buffer, this.p4);
        return buffer;
    }
}
export class Tsm_Casino_Action {
    constructor(buffer) {
        let parse = new SocketHelper();
        this.errorNo = parse.getInt(buffer);
        this.gameType = parse.getInt(buffer);
        this.actionType = parse.getInt(buffer);
        this.action = parse.getUInt(buffer);
        this.p1 = parse.getInt(buffer);
        this.p2 = parse.getInt(buffer);
        this.p3 = parse.getInt(buffer);
        this.p4 = parse.getInt(buffer);
    }
}
export class Tsm_Casino_Tips {
    constructor(buffer) {
        let parse = new SocketHelper();
        this.gameType = parse.getInt(buffer);
        this.tipsNo = parse.getUInt(buffer);
        this.p1 = parse.getInt(buffer);
        this.p2 = parse.getInt(buffer);
        this.p3 = parse.getInt(buffer);
        this.p4 = parse.getInt(buffer);
    }
}
export class ResultVo {
    constructor(buffer) {
        let sock = new SocketHelper();
        this.memberId = sock.getInt(buffer);
        this.uid = sock.getUInt64(buffer);
        this.winGolds = sock.getInt64(buffer);
        this.loseGolds = sock.getInt64(buffer);
        this.sessionId = sock.getUInt(buffer);
        this.dbId = sock.getUShort(buffer);
        this.srvId = sock.getUShort(buffer);
        this.lineId = sock.getUShort(buffer);
        this.platformId = sock.getInt(buffer);
        this.roomId = sock.getInt(buffer);
        this.cardType = sock.getInt(buffer);
        this.nowGolds = sock.getUInt64(buffer);
        this.isWin = sock.getChar(buffer);
    }
}
export class Tsm_Casino_Result {
    constructor(buffer) {
    }
}
export class Tsm_Casino_ChangeAction {
    constructor(buffer) {
        let reader = new SocketHelper();
        this.gameType = reader.getInt(buffer);
        this.actionType = reader.getInt(buffer);
        this.action = reader.getUInt(buffer);
        this.p1 = reader.getInt(buffer);
        this.p2 = reader.getInt(buffer);
        this.p3 = reader.getInt(buffer);
        this.p4 = reader.getInt(buffer);
    }
}
